<?php
class JobController extends AppController {
	var $name = 'Job';
	var $components = array('Slug');
	var $scaffold;
	
	function beforeFilter() {
	}
	
	function add() {
		if ($this->data['Job']['job_name'] && $this->data['Job']['job_date']) {
			//	create slug
			$this->data['Job']['slug'] = $this->Slug->createSlug($this->data['Job']['job_name']);
			
			//	set data and validate
			$this->Job->set($this->data);
			$validated = $this->Job->validates();
			
			if ($validated) {
				$this->Job->save();
				
				//	go to the list
				$this->Session->setFlash(__("Data saved."));
				$this->redirect(array('controller' => 'job', 'action' => '/'), null, true);
			} else {
				$this->Session->setFlash(__("Data cannot saved."), null);
			}
		}
	}
	
	function all() {
	}
	
	function view($jobSlug) {
		$job = $this->Job->find("all", array('slug' => $jobSlug));
		die($job['job_name']);
	}
}
?>